package com.kcht.sylyg08.ctrl;

import com.kcht.adp.common.log.Logger;
import com.kcht.adp.pagination.Page;
import com.kcht.adp.web.rs.AdpRest;
import com.kcht.sylyg08.service.AntService;
import com.kcth.sylyg08.entity.Ant;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.ws.rs.QueryParam;
import java.util.List;

/**
 * @program: G08ProductionLine
 * @description 天线管理的controller层，前端直接调用
 * @author: X.Gao
 * @create: 2019-07-25 08:53
 **/

@RequestScoped
@Transactional(Transactional.TxType.NOT_SUPPORTED)
public class AntCtrl {

    @Inject
    private Logger logger;

    @Inject
    private AntService antService;

    //对数据库中天线信息进行分页查询，并返回给前端
    @AdpRest(principal = "天线管理", permission = "天线管理")
    public Page<Ant, Ant> list(Page<Ant, Ant> page) {

        return antService.list(page);

    }

    //保存新增天线信息，如果没有保存成功，则给前端返回null
    @AdpRest(principal = "天线管理", permission = "天线管理")
    public String save(Ant ant) {

        if (antService.save(ant)) {

            return "";

        } else {

            return null;

        }

    }

    //删除天线
    @AdpRest(principal = "天线管理", permission = "天线管理")
    public void delete(@QueryParam("ids") List<Integer> ids) {
        antService.delete(ids);
    }

}
